import {Module,forwardRef} from '@nestjs/common';
import { UserController,jwtConstants } from './user.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from "../../entity/user.entity"
import { UserService } from './user.service'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { JwtModule } from '@nestjs/jwt'
import { AuthModule } from '../auth/auth.module'
import { PassportModule } from '@nestjs/passport';
import { LocalStrategy } from '../strategy/local.strategy';
import { JwtStrategy } from '../strategy/jwt.strategy';
@Module({

    imports:[
        TypeOrmModule.forFeature([User]),
        JwtModule.register({
            secret: jwtConstants.secret,
            signOptions: { expiresIn: '24h' },
        }),
        PassportModule.register({ defaultStrategy: 'jwt' })
        // AuthModule,
        // forwardRef(() => AuthModule),
        // JwtModule.registerAsync({
        //     imports: [ConfigModule],
        //     useFactory: async (config: ConfigService) => ({
        //         secret: config.get('JWT.secretKey'),
        //         signOptions: {
        //             expiresIn: config.get('JWT.expiresIn')
        //         }
        //     }),
        //     inject: [ConfigService]
        // })
    ],
    controllers: [UserController],
    providers:[UserService,LocalStrategy, JwtStrategy],
    exports: [UserService]
})
export class UserModule {}
